package com.market.dao;

import com.market.domain.OrderDetail;

public interface OrderDetailDao extends GenericDao<OrderDetail, Long> {

	/**
	 * First the inventory of product corresponding to this order detail will be
	 * update, product.inventory = product.inventory -
	 * orderDetail.deliveredQuantity. then this order detail will be saved to
	 * DB. If the order corresponding to this order detail is Confirmed,invoke
	 * removeAndUpdateInventory to return deliveredQuantity first, and invoke
	 * the method save and update inventory.
	 * 
	 * @param orderDetail
	 * @return
	 */
	public OrderDetail saveAndUpdateInventory(OrderDetail orderDetail);

	/**
	 * This method remove order detail from DB, the inventory of product
	 * corresponding to this order detail will be updated, product.inventory =
	 * product.inventory + orderDetail.getDeliveredQuantity
	 * 
	 * @param orderDetal
	 * @return
	 */
	public void removeAndUpdateInventory(OrderDetail orderDetal);
	
	/**
	 * This method minus deliveredQuantity from inventory
	 * 
	 * @param orderDetal
	 */
	
	public OrderDetail confirm(OrderDetail orderDetal);

	
	
	/**
	 * This method restore deliveredQuantity to inventory, and set
	 * deliveredQuantity and deliveredPrice to Zero
	 * 
	 * @param orderDetal
	 */
	public OrderDetail unConfirm(OrderDetail orderDetal);
}
